<?php

namespace app\common\controller;

use think\Controller;
use think\Session;

class MemberBase extends Controller
{

    protected function _initialize()
    {
        parent::_initialize();

        //判断是否登录
        if (!Session::has('uid') || !Session::has('token')) {
            Session::set('uid', null);
            Session::set('token', null);
            Session::set('name', null);
            Session::set('time_out', null);
            $this->redirect('member/login/index');
        }

        //超时
        $time = $_SERVER['REQUEST_TIME'];
        if($time > Session::get('time_out')) {
            Session::set('uid', null);
            Session::set('token', null);
            Session::set('name', null);
            Session::set('time_out', null);
            $this->redirect('member/login/index');
        }
    }

}